<?php
$cli = new swoole_http_client('http://www.baidu.com', 80);

$cli->setHeaders([
    'Host' => "localhost",
    "User-Agent" => 'Chrome/49.0.2587.3',
    'Accept' => 'text/html,application/xhtml+xml,application/xml',
    'Accept-Encoding' => 'gzip',
]);

$cli->get('/', function ($cli) {
    echo "Length: " . strlen($cli->body) . "\n";
    echo $cli->body;
});